package com.wfy.modules.openInterface.common;

/**
 * Created with IntelliJ IDEA.
 * User: wangxindong
 * Date: 2017/9/27
 * Time: 16:58
 */
public enum SensorStatusEnum {

    normal(0, "正常"),
    Unknown(-1, "未知"),
    warning(1, "报警"),
    maintain(2, "维修");

    private int status;
    private String msg;

    SensorStatusEnum(int status, String msg) {
        this.status = status;
        this.msg = msg;
    }

    public int getStatus() {
        return status;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 根据key获取value
     *
     * @param key : 键值key
     * @return String
     */
    public static String getValueByKey(int key) {
        SensorStatusEnum[] enums = SensorStatusEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getStatus() == key) {
                return enums[i].getMsg();
            }
        }
        return "";
    }
}
